﻿namespace HauWei.RepUtils
{
    using DevExpress.XtraReports.UI;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Windows.Forms;

    public class FrmRepBase : Form
    {
        private DataSet dataSet;
        private IContainer icontainer;
        private PreviewControl previewControl = new PreviewControl();
        private PreviewControl previewControl2 = new PreviewControl();
        private string str;
        private string str1;
        private XtraReport xtraReport;

        public FrmRepBase()
        {
            this.InitializeComponent();
        }

        public FrmRepBase(string fileName, DataSet ds, string appPath)
        {
            this.InitializeComponent();
            this.str = fileName;
            this.dataSet = ds;
            this.str1 = appPath;
        }

        protected void Dispose(bool disposing)
        {
            if (disposing && (this.icontainer != null))
            {
                this.icontainer.Dispose();
            }
        }

        private void InitializeComponent()
        {
            this.previewControl2 = new PreviewControl();
            base.SuspendLayout();
            this.previewControl2.Dock = DockStyle.Bottom;
            this.previewControl2.FileName = null;
            this.previewControl2.Location = new Point(0, 0x21);
            this.previewControl2.Name = "previewControl2";
            this.previewControl2.RepDs = null;
            this.previewControl2.Report = null;
            this.previewControl2.Size = new Size(0x356, 0x162);
            this.previewControl2.TabIndex = 0;
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            base.ClientSize = new Size(0x356, 0x183);
            base.Controls.Add(this.previewControl2);
            base.Name = "FrmRepBase";
            this.Text = "FrmRepBase";
            base.ResumeLayout(false);
        }

        private void method(object sender, EventArgs e)
        {
            if (!File.Exists(this.str))
            {
                File.Copy(this.str1 + @"RepFile\RepBase.repx", this.str);
            }
            this.xtraReport = XtraReport.FromFile(this.str, true);
            this.xtraReport.ExportToXls("c:\aaa.XLS");
            this.xtraReport.DataSource = this.dataSet;
            this.previewControl.RepDs = this.dataSet;
            this.previewControl.Report = this.xtraReport;
            this.previewControl.FileName = this.str;
        }
    }
}

